package com.sa35.fbs.dao.impl;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.sa35.fbs.dao.UserDao;
import com.sa35.fbs.dao.util.DaoUtil;
import com.sa35.fbs.model.User;

@Repository
public class UserDaoImpl extends GenericHibernateDao<User, Long> implements
		UserDao {
	@Override
	public User findByUserName(String userName) {
		logger.info("get user by user name : {}" ,userName);
		return DaoUtil.getFirstElement(getHibernateTemplate().findByCriteria(
				DetachedCriteria.forClass(getDomainClass()).add(
						Restrictions.eq("userName", userName))));
	}
}
